// erc-巡检计划
import { http } from "@/utils/http";

export type ResultTable<T> = Partial<{
  total?: number;
  pageNum: number;
  pageSize: number;
  data?: Array<T>;
}>;

export type checkTreeItemType = {
  id?: string;
  parentId?: string;
  name?: string;
  children?: checkTreeItemType[];
  code?: string;
  parentCode?: string;
  path?: string;
  facCode?: string;
  orderSeq?: number;
  status?: string;
  createBy?: number;
  createByName?: string;
  createTime?: string;
  updateBy?: number;
  updateByName?: string;
  updateTime?: string;
};
export type equipTableItem = Partial<{
  id: number; //主键id
  eqpId: string; //设备编码
  eqpName: string; //设备名称
  facCode: string; //地块区域编码
  facName: string; //地块区域名称
  typeCode: string; //设备类型编码
  typeName: string; //设备类型名称
  typeNameAll: string; //设备类型全层级名称
  positionCode: string; //设备位置编码
  positionName: string; //设备位置名称
  positionNameAll: string; //设备位置全层级名称
  specification: string; //规格型号
  brand: string; //品牌
  eqpStatus: string; //设备状态:正常1,故障2 报废3 隔离4 未接入5
  eqpDoc: string; //设备文档
  sparePartId: string; //设备备件
}>;

//查询巡检区域树
export const queryCheckAreaTree = (data?: object) => {
  return http.request<checkTreeItemType[]>("post", "/erc/api/v1/position/queryTree", {
    data
  });
};
//查询设备巡检规则
export const queryEquipInspectPlan = (data?: object) => {
  return http.request<ResultTable<any>>("post", "/erc/api/v1/checkRule/pageList", {
    data
  });
};
//查询设备列表
export const queryEquipTable = (data?: object) => {
  return http.request<ResultTable<equipTableItem>>("post", "/erc/api/v1/eqp/queryList", {
    data
  });
};
//保存
export const saveInspectPlan = (data?: object) => {
  return http.request<ResultTable<any>>("post", "/erc/api/v1/checkPlan/save", {
    data
  });
};
//获取计划编号

export const getInspectPlanCode = (data?: object) => {
  return http.request<string>("post", "/erc/api/v1/checkPlan/getPlanNo", {
    data
  });
};
//获取巡检组
export const getGroupList = (data?: object) => {
  return http.request<Array<any>>("post", "/erc/api/v1/opsGroup/queryList", {
    data
  });
};
//获取巡检table数据
export const getInspectPlanTable = (data?: object) => {
  return http.request<ResultTable<any>>("post", "/erc/api/v1/checkPlan/pageList", {
    data
  });
};
//删除巡检项
export const deleteInspectPlanTable = (id?: string) => {
  return http.request<ResultTable<any>>("post", `/erc/api/v1/checkPlan/delById/${id}`);
};
//获取巡检计划详情
export const getByPlanNo = (data?: object) => {
  return http.request<ResultTable<any>>("post", `/erc/api/v1/checkPlan/getByPlanNo`, {
    data
  });
};
//更新
export const updateInspectPlan = (data?: object) => {
  return http.request<ResultTable<any>>("post", "/erc/api/v1/checkPlan/update", {
    data
  });
};
//发布
export const publicInspectPlan = (data?: object) => {
  return http.request<ResultTable<any>>("post", "/erc/api/v1/checkPlan/publish", {
    data
  });
};
